home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 22 / AACD 22.iso / AACD / Graphics / FlashMandel / Sources / Modules / Mandel68K.S < prev    next >
Encoding:
Text File  |  2001-05-20  |  4.4 KB  |  108 lines

  1. ************************************************************************
  2. **            Written by Dino Papararo            25-April-2001
  3. **
  4. **  FUNCTION
  5. **
  6. **    Mandel -- perform Z = Z^2 + C iteration.
  7. **
  8. **  SYNOPSIS
  9. **
  10. **    WORD Mandel (WORD Iterations,double Cre,double Cim)
  11. **
  12. **
  13. **  DESCRIPTION
  14. **
  15. **  C equivalent function:
  16. **
  17. **      ***************************************************************
  18. **      *WORD Mandel (WORD Iterazioni,double Cre,double Cim)        ***
  19. **      *{                                                          ***
  20. **      *register double zr,zi,zi2,dist,maxdist;                    ***
  21. **      *                                                           ***
  22. **      *  zi = Cim;                                                ***
  23. **      *                                                           ***
  24. **      *  zr = Cre;                                                ***
  25. **      *                                                           ***
  26. **      *  maxdist = 4;                                             ***
  27. **      *                                                           ***
  28. **      *  do {                                                     ***
  29. **      *       zi2 = zi;                                           ***
  30. **      *                                                           ***
  31. **      *       zi  *= zr;                                          ***
  32. **      *                                                           ***
  33. **      *       zr  *= zr;                                          ***
  34. **      *                                                           ***
  35. **      *       zi2 *= zi2;                                         ***
  36. **      *                                                           ***
  37. **      *       dist = zr;                                          ***
  38. **      *                                                           ***
  39. **      *       dist += zi2;                                        ***
  40. **      *                                                           ***
  41. **      *       if (dist > maxdist) return Iterazioni;              ***
  42. **      *                                                           ***
  43. **      *       zi += zi;                                           ***
  44. **      *                                                           ***
  45. **      *       zr -= zi2;                                          ***
  46. **      *                                                           ***
  47. **      *       zi += Cim;                                          ***
  48. **      *                                                           ***
  49. **      *       zr += Cre;                                          ***
  50. **      *                                                           ***
  51. **      *     } while (-- Iterazioni);                              ***
  52. **      *                                                           ***
  53. **      *  return 0;                                                ***
  54. **      *}                                                          ***
  55. **      ***************************************************************
  56. **
  57. **  This function tests if a point belongs or not at mandelbrot's set
  58. **
  59. **  Optimized for pipelines of 68882+ coprocessors
  60. **
  61. **  NOTICE: ALL VARIABLES ARE INTO REGISTERS FOR FULL SPEEEED
  62. **
  63. **  d0:Iterations
  64. **
  65. **  fp0:Cre fp1:Cim fp2:Zr fp3:Zi fp4:Zi2 fp5:Zr2/Dist fp6:MaxDist fp7:NotUsed ;-)
  66. ******************************************************************************
  67.  
  68. *        MACHINE  68060
  69.  
  70.         XDEF  _Mandel68K
  71.  
  72.         section data
  73.  
  74. Radius  dc.x  4.0
  75.  
  76.         section code
  77.  
  78. _Mandel68K:
  79.  
  80.  
  81.         fmove.x fp1,fp3      * Zi = Cim
  82.         fmove.x fp0,fp2      * Zr = Cre
  83.         fmove.x Radius,fp6   * MaxDist = 4.0
  84.  
  85. Loop:
  86.  
  87.         fmove.x fp3,fp4      * zi2   = zi
  88.         fmul.x  fp2,fp3      * zi    = zr * zi
  89.         fmul.x  fp2,fp2      * zr    = zr * zr
  90.         fmul.x  fp4,fp4      * zi2   = zi * zi
  91.         fmove.x fp2,fp5      * dist  = zr2
  92.         fadd.x  fp4,fp5      * dist += zi2
  93.         fcmp.x  fp6,fp5      * Compare MaxDist & Dist
  94.         fbgt.w  Exit         * if Dist > MaxDist then goto Exit
  95.         fadd.x  fp3,fp3      * zi   += zi
  96.         fsub.x  fp4,fp2      * zr   -= zi2
  97.         fadd.x  fp1,fp3      * zi   += Cim
  98.         fadd.x  fp0,fp2      * zr   += Cre
  99.  
  100.         dbra.w  d0,Loop      * if --Iterations != -1 go to Loop
  101.         clr.w   d0           * Iterations = 0
  102.  
  103. Exit:
  104.  
  105.         rts                  * return Iterations
  106.  
  107.         end
  108.